#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,i,j,d[100005],v[100005],a[100005],p[100005],cnt;
bool bookp[100005],bb[100005];
struct Car{
    int bg,ed;
    bool book;
}car[100005];
bool cmp(Car x, Car y){
    if(x.bg==y.bg){
        return x.ed<y.ed;
    }
    return x.bg<y.bg;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(i=1;i<=m;i++){
            scanf("%d",&p[i]);
            bookp[p[i]]=1;
        }
        sort(p+1,p+m+1);
        for(i=1;i<=n;i++)
        {
            if(a[i]==0){
                if(v[i]>V){
                    car[i].bg=d[i];
                    car[i].ed=L;
                    if(d[i]<=p[m]){
                        car[i].book=1;
                    }
                }
            }
            else if(a[i]>0){
                if(v[i]>V){
                    car[i].bg=d[i];
                    car[i].ed=L;
                    if(d[i]<=p[m]) car[i].book=1;
                }
                else if(v[i]==V){
                    car[i].bg=d[i]+1;
                    car[i].ed=L;
                    if(d[i]<p[m]) car[i].book=1;
                }
                else{
                    int dd;
                    dd=d[i]+(V*V-v[i]*v[i])*0.5/a[i]+1;
                    if(dd<=L){
                        car[i].bg=dd;
                        car[i].ed=L;
                        car[i].book=1;
                    }
                }
            }
            else{
                if(v[i]>V){
                    int dd;
                    dd=d[i]+(V*V-v[i]*v[i])*0.5/a[i];
                    car[i].bg=d[i];
                    car[i].ed=dd;
                    for(j=1;j<=n;j++){
                        if(p[i]>car[i].ed) break;
                        if(p[i]>=car[i].bg){
                            car[i].book=1;
                            break;
                        }
                    }
                }
            }
        }
        int tot=0;
        for(i=1;i<=n;i++) tot+=car[i].book;
        printf("%d ",tot);
        sort(car+1,car+n+1,cmp);
        for(i=1;i<=n;i++){
            if(!bb[i]&&car[i].book){
                cnt++;
                bb[i]=1;
                int k;
                for(j=car[i].ed;j>=car[i].bg;j--)
                    if(bookp[j]){
                        k=j;
                        break;
                    }
                for(j=i+1;j<=n;j++){
                    if(car[j].bg>k) break;
                    if(car[j].ed>=k) bb[j]=1;
                }
            }
        }
        printf("%d\n",m-cnt);
    }
    return 0;
}
